#include "CBase.h"
#include "SGD Wrappers\CSGD_TextureManager.h"
#include "CCamera.h"

CBase::CBase()
{
	m_uiRefCount = 1;
	SetPosX(0);
	SetPosY(0);
	SetVelX(0);
	SetVelY(0);
	SetImageID(-1);
	SetWidth(0);
	SetHeight(0);
}

CBase::~CBase()
{
}

RECT CBase::GetRect()
{
	RECT temprect = {(int)m_fXPos, (int)m_fYPos, (int)m_fXPos + m_nWidth, (int)m_fYPos + m_nHeight};
	return temprect;
}

void CBase::Update(float fElapsedTime)
{
	SetPosX(GetPosX() + (GetVelX() * fElapsedTime));
	SetPosY(GetPosY() + (GetVelY() * fElapsedTime));
}

void CBase::Render()
{
	CSGD_TextureManager::GetInstance()->Draw(GetImageID(), (int)(GetPosX() - CCamera::GetInstance()->GetPosX()),
											(int)(GetPosY() - CCamera::GetInstance()->GetPosY()));
}

bool CBase::CheckCollision(IBaseInterface* pBase)
{
	RECT result;
	if(IntersectRect(&result, &GetRect(), &pBase->GetRect()))
		return true;
	return false;
}